﻿using Common.Communal;
using ERP.Domain.Products;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Product.API.Read.Applications.Commands.Process;
using Repository.communal;


namespace Product.API.Read.Controllers
{
    /// <summary>
    /// 工序API-读
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class ProcessController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public ProcessController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 工序显示
        /// </summary>
        /// <returns>返回任务</returns>
        [HttpGet("Process")]
        public Task<ApiResult<List<ERP.Domain.Products.Process>>> Process()
        {
            ProcessShowCommand command = new ProcessShowCommand();
            return mediator.Send(command);
        }

        /// <summary>
        /// 工艺路线编号查询
        /// </summary>
        /// <param name="Id">主键</param>
        /// <returns>返回单条</returns>
        [HttpGet("GetProcessById")]
        public Task<ApiResult<List<ERP.Domain.Products.Process>>> GetProcessById(Guid processRouteNumber)
        {
            GetProcessByIdCommand command = new GetProcessByIdCommand();
            command.processRouteNumber = processRouteNumber;
            return mediator.Send(command);
        }

    }
}
